package com.autumn.annotations.bean.config;

import com.autumn.annotations.bean.config.filter.TypeFilterImpl;
import com.autumn.annotations.bean.controller.BaseController;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

/**
 * ClassName: BaseConfig
 *
 * @Description:
 * @Author: wangqiuyang
 * @Date: 2021/12/15 下午8:47
 * History:
 * <author>          <time>          <version>          <desc>
 * wangqiuyang    2021/12/15 下午8:47   @Version 1.0        描述
 */
@ComponentScan(value = "com.autumn.annotations.bean" ,excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION , classes = {
                Controller.class , Service.class
        }),
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE , classes = {
                BaseController.class // 过滤某个类型的bean 只要实现了或继承了BaseController的类都会被加载进来
        }),
        @ComponentScan.Filter(type = FilterType.CUSTOM , classes = {
                TypeFilterImpl.class // 源码提示需要给定一个 TypeFilter 的实现类 类实现match方法匹配bean规则
        }) // 层层过滤 下面的filter 会过滤上一个filter 过滤之后的bean
})

/*
    @ComponentScan(value = "com.autumn.bean" , includeFilters = {
            @ComponentScan.Filter(type = FilterType.ANNOTATION , classes = {
                    Controller.class
                })
            } // 只要controller注解的bean
           ,useDefaultFilters = false // 不使用默认的过滤规则 设置之后 includeFilters 才能生效
    ) // includeFilters 和 useDefaultFilters配合使用
*/
// jdk 1.8 ComponentScan 中有 Repeatable 注解 可以在configuration 上面添加多个 componentScan注解
// 或者使用componentScans  里面可以写多个componentsScan注解



@Configuration
public class BaseConfig {

}
